package com.example.triprec.ui.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.example.triprec.R;
import com.gzone.university.adapter.ItemViewHolder;
import com.gzone.university.adapter.ViewAdapter;

import java.util.ArrayList;
import java.util.List;

public class ScenicDetailTagAdapter extends ViewAdapter<ScenicDetailTagAdapter.ViewHolder> {

    private final List<String> list = new ArrayList<>();

    public ScenicDetailTagAdapter(View view) {
        super(view);
    }

    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent) {
        return new ViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_scenic_detail_tag, parent, false));
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder) {
        String tag = list.get(holder.getAdapterPosition());
        holder.tvScenicTag.setText(tag);
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    public void setData(List<String> list) {
        this.list.clear();
        if (list != null) {
            this.list.addAll(list);
        }
        notifyDataSetChanged();
    }

    public static class ViewHolder extends ItemViewHolder {

        private final TextView tvScenicTag;

        public ViewHolder(View itemView) {
            super(itemView);
            tvScenicTag = itemView.findViewById(R.id.tv_scenic_tag);
        }
    }
}
